package net.homelinux.chaoswg.io.renga.krypto.animations.Pht;

import net.homelinux.chaoswg.io.renga.core.animations.State;
import net.homelinux.chaoswg.io.renga.krypto.datatypes.numerical.Unsigned8Bit;
import net.homelinux.chaoswg.io.renga.krypto.datatypes.numerical.UnsignedNBit;
import net.homelinux.chaoswg.io.renga.krypto.datatypes.numerical.UnsignedNBitFactory;

public class PhtState implements State {
    UnsignedNBit operand0 = new Unsigned8Bit ();
    UnsignedNBit operand1 = new Unsigned8Bit ();
    UnsignedNBit result0 = new Unsigned8Bit ();
    UnsignedNBit result1 = new Unsigned8Bit ();
    
    int step = 0;
    
    public PhtState () {} 
    
    public PhtState (UnsignedNBit operand0, UnsignedNBit operand1) {
        this.operand0 = operand0;
        this.operand1 = operand1;
        
        UnsignedNBitFactory unbf = UnsignedNBitFactory.createUnsignedNBitFactory();
        
        this.result0 = unbf.get(operand0.getN());
        this.result1 = unbf.get(operand0.getN());
    }
    
    public UnsignedNBit getOperand0() {
        return operand0;
    }
    public void setOperand0(UnsignedNBit operand0) {
        this.operand0 = operand0;
    }
    public UnsignedNBit getOperand1() {
        return operand1;
    }
    public void setOperand1(UnsignedNBit operand1) {
        this.operand1 = operand1;
    }
    public UnsignedNBit getResult0() {
        return result0;
    }

    public int getStep() {
        return step;
    }

    public void setStep(int step) {
        this.step = step;
    }

    public UnsignedNBit getResult1() {
        return result1;
    }

    public void setResult1(UnsignedNBit result1) {
        this.result1 = result1;
    }

    public void setResult0(UnsignedNBit result0) {
        this.result0 = result0;
    }

    public void setOperand(final int slot, final Object value) {
        if (value instanceof UnsignedNBit) {
            UnsignedNBitFactory unbf = UnsignedNBitFactory.createUnsignedNBitFactory();

            switch (slot) {
                case 0:
                    operand0 = ((UnsignedNBit)value);
                    this.result0 = unbf.get(operand0.getN());
                    this.result1 = unbf.get(operand0.getN());
                    break;
                case 1:
                    operand1 = ((UnsignedNBit)value);
                    this.result0 = unbf.get(operand1.getN());
                    this.result1 = unbf.get(operand1.getN());
                    
                    break;
            }
        }
    }

}
